'
结束场景菜单
'

extends CanvasLayer

@onready var panel_container: PanelContainer = %PanelContainer

#暂停游戏并弹出该页面
func _ready() -> void:
	get_tree().paused = true
	$"%RestartButton".pressed.connect(on_restart_button_pressed)
	$"%QuitButton".pressed.connect(on_quit_button_pressed)
	var tween = self.create_tween()
	panel_container.pivot_offset = panel_container.size / 2
	tween.tween_property(panel_container, "scale", Vector2.ZERO, 0)
	tween.tween_property(panel_container, "scale", Vector2.ONE, .3)\
	.set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_BACK)
	pass

#设置结局
func set_ending(victory: bool = true) -> void:
	if victory:
		$%TitleLabel.text = "Victory"
		$%DescriptionLabel.text = "You win!"
		$VictoryStreamPlayer.play()
	else:
		$%TitleLabel.text = "Defeat"
		$%DescriptionLabel.text = "You lost!"
		$DefeatStreamPlayer.play()
	pass

#再开一局
func on_restart_button_pressed() -> void:
	get_tree().paused = false
	ScreenTransition.change_screen("res://场景/主场景/main.tscn")
	pass

#返回主菜单
func on_quit_button_pressed() -> void:
	get_tree().paused = false
	ScreenTransition.change_screen("res://场景/ui/主菜单.tscn")
	pass
